var limsQualitycontrolTestBatch = Gikam.getPageObject({

    getEditListColumns: function () {
        return [{
            checkbox: true
        }, {
            index: true
        }, {
            field: 'qualityControlTestBatchCode',
            title: 'T_LIMS_QUALITYCONTROL_TEST_BATCH.QUALITYCONTROLTESTBATCHCODE'
        }, {
            field: 'createdByName',
            title: 'T_LIMS_QUALITYCONTROL_TEST_BATCH.CREATEDBYNAME'
        }, {
            field: 'createdTime',
            title: 'T_LIMS_QUALITYCONTROL_TEST_BATCH.CREATEDTIME'
        }];
    },

    getBaseInfoFormFields: function () {
        return [{
            field: 'qualityControlTestBatchCode',
            title: 'T_LIMS_QUALITYCONTROL_TEST_BATCH.QUALITYCONTROLTESTBATCHCODE',
            validators: ['strLength[0,16]']
        },];
    },

    getResultEditListColumns: function (readonly) {
        var editor = true
        if (readonly) {
            editor = false
        }
        return [{
            checkbox: true
        }, {
            index: true
        }, {
            field: 'identifyCode',
            title: 'T_LIMS_QUALITYCONTROLPLAN.IDENTIFYCODE'
        }, {
            field: 'controlMaterialName',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.CONTROLMATERIALNAME',
            type: 'link'
        }, {
            field: 'mainBatchCode',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.MAINBATCHCODE'
        }, {
            field: 'controlMaterialLevel',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.CONTROLMATERIALLEVEL',
            type: 'select',
            category: 'sys',
            multiple: true,
            param: {
                codeCategoryId: 'controlMaterialLevel'
            }
        }, {
            field: 'equipmentName',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.EQUIPMENTNAME'
        }, {
            field: 'ext$.professionalgrouptext',
            title: 'T_LIMS_QUALITYCONTROLPLAN.PROFESSIONALGROUP',
            // field: 'professionalGroup',
            // title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.PROFESSIONALGROUP',
            // type: 'select',
            // category: 'sys',
            // param: {
            //     codeCategoryId: 'qualityControl-professionalGroup'
            // },
        }, {
            field: 'productCode',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.PRODUCTCODE'
        }, {
            field: 'productName',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.PRODUCTNAME'
        }, {
            field: 'methodDesc',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.METHODDESC'
        }, {
            field: 'targetValue',
            title: 'T_LIMS_QUALITYCONTROLPLAN_PROJECT.TARGETVALUE',
            editor: editor,
            type: 'number',
            onChange: function (field, value, index, oldValue, text) {
                var grid = this
                var data = grid.options.data[index]
                var numberValidate = Gikam.validator.number(value);
                // 不触发自动保存
                this.setData({
                    index: index,
                    targetValue: value
                }, false);
                workspace.window.showMask()
                Gikam.postText(limsQualitycontrolTestBatch.resultBaseUrl + '/update-testresult',
                    Gikam.getJsonWrapper({
                        oldValue: oldValue,
                        field: field
                    }, ['', [data]])).done(function () {
                    grid.refresh()
                }).always(function () {
                    workspace.window.closeMask()
                })
            }
        }, {
            field: 'standardDeviation',
            title: 'T_LIMS_QUALITYCONTROLPLAN_PROJECT.STANDARDDEVIATION',
            editor: editor,
            type: 'number',
            onChange: function (field, value, index, oldValue, text) {
                var grid = this
                var data = grid.options.data[index]
                var numberValidate = Gikam.validator.number(value);
                // 不触发自动保存
                this.setData({
                    index: index,
                    standardDeviation: value
                }, false);
                workspace.window.showMask()
                Gikam.postText(limsQualitycontrolTestBatch.resultBaseUrl + '/update-testresult',
                    Gikam.getJsonWrapper({
                        oldValue: oldValue,
                        field: field
                    }, ['', [data]])).done(function () {
                    grid.refresh()
                }).always(function () {
                    workspace.window.closeMask()
                })
            }
        }, {
            field: 'cvValue',
            title: 'T_LIMS_QUALITYCONTROLPLAN_PROJECT.CVVALUE',
            editor: editor,
            type: 'number',
            onChange: function (field, value, index, oldValue, text) {
                var grid = this
                var data = grid.options.data[index]
                var numberValidate = Gikam.validator.number(value);
                // 不触发自动保存
                this.setData({
                    index: index,
                    cvValue: value
                }, false);
                workspace.window.showMask()
                Gikam.postText(limsQualitycontrolTestBatch.resultBaseUrl + '/update-testresult',
                    Gikam.getJsonWrapper({
                        oldValue: oldValue,
                        field: field
                    }, ['', [data]])).done(function () {
                    grid.refresh()
                }).always(function () {
                    workspace.window.closeMask()
                })
            }
        }, {
            field: 'testResult',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.TESTRESULT',
            editor: editor,
            type: 'number',
            onChange: function (field, value, index, oldValue, text) {
                var grid = this
                var data = grid.options.data[index]
                var numberValidate = Gikam.validator.number(value);
                // 不触发自动保存
                this.setData({
                    index: index,
                    testResult: value,
                    resultSaveTime: Gikam.DateUtils.formatter(new Date(), 'yyyy-MM-dd hh:mm:ss'),
                }, false);
                workspace.window.showMask()
                Gikam.postText(limsQualitycontrolTestBatch.resultBaseUrl + '/update-testresult',
                    Gikam.getJsonWrapper({
                        oldValue: oldValue,
                        field: field
                    }, ['', [data]])).done(function () {
                    grid.refresh()
                }).always(function () {
                    workspace.window.closeMask()
                })
            }
        }, {
            field: 'resultSaveTime',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.RESULTSAVETIME',
            type: 'dateTime',
            editor: editor,
            onChange: function (field, value, index, oldValue, text) {
                var grid = this
                var data = grid.options.data[index]
                // 不触发自动保存
                this.setData({
                    index: index,
                    resultSaveTime: value
                }, false);
                workspace.window.showMask()
                Gikam.postText(limsQualitycontrolTestBatch.resultBaseUrl + '/update-testresult',
                    Gikam.getJsonWrapper({
                        oldValue: oldValue,
                        field: field
                    }, ['', [data]])).done(function () {
                    grid.refresh()
                }).always(function () {
                    workspace.window.closeMask()
                })
            }
        }, {
            field: 'createdByName',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.CREATEDBYNAME'
        }, {
            field: 'createdTime',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.CREATEDTIME',
            type: 'dateTime'
        },{
            field: 'submitByName',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.SUBMITBYNAME'
        }, {
            field: 'submitTime',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.SUBMITTIME',
            type: 'dateTime'
        },];
    },

    getResultBaseInfoFormFields: function () {
        return [{
            field: 'controlMaterialName',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.CONTROLMATERIALNAME',
            validators: ['strLength[0,33]'],

        }, {
            field: 'mainBatchCode',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.MAINBATCHCODE',
            validators: ['strLength[0,33]'],
            type: 'choose',
            category: 'qualitycontrolplan-choose-list',
            single: true,
            onAfterChoose: function (data, index) {
                if (data) {
                    console.log(data)
                    this.setData({})
                }
            },
            preInsert: true
        }, {
            field: 'controlMaterialLevel',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.CONTROLMATERIALLEVEL',
            validators: ['strLength[0,66]']
        }, {
            field: 'equipmentName',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.EQUIPMENTNAME',
            validators: ['strLength[0,33]']
        }, {
            field: 'professionalGroup',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.PROFESSIONALGROUP',
            validators: ['strLength[0,66]']
        }, {
            field: 'productCode',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.PRODUCTCODE',
            validators: ['strLength[0,33]']
        }, {
            field: 'productName',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.PRODUCTNAME',
            validators: ['strLength[0,33]']
        }, {
            field: 'methodDesc',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.METHODDESC',
            validators: ['strLength[0,33]']
        }, {
            field: 'testResult',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.TESTRESULT',
            validators: ['strLength[0,66]']
        }, {
            field: 'resultSaveTime',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.RESULTSAVETIME'
        }, {
            field: 'targetValue',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.TARGETVALUE',
            validators: ['strLength[0,33]']
        }, {
            field: 'standardDeviation',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.STANDARDDEVIATION',
            validators: ['strLength[0,33]']
        }, {
            field: 'cvValue',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.CVVALUE',
            validators: ['strLength[0,33]']
        }, {
            field: 'controlRule',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.CONTROLRULE',
            validators: ['strLength[0,66]']
        }, {
            field: 'qualityControlTestBatchCode',
            title: 'T_LIMS_QUALITYCONTROL_TEST_RESULT.QUALITYCONTROLTESTBATCHCODE',
            validators: ['strLength[0,33]']
        }];
    },

    resultBaseUrl: IFM_CONTEXT + '/secure/basemodule/business/qualitycontrol/qualitycontrol-test-results',
    baseUrl: IFM_CONTEXT + '/secure/basemodule/business/qualitycontrol/qualitycontrol-test-batchs',
    editRecordUrl: IFM_CONTEXT + '/secure/baseline/business/edit-records',


    getOrderTaskEditRecordColumns: function () {
        return [{
            index: true
        }, {
            field: 'fromValue',
            title: 'T_LIMS_EDIT_RECORD.FROMVALUE',
            width: 160
        }, {
            field: 'toValue',
            title: 'T_LIMS_EDIT_RECORD.TOVALUE',
            width: 160
        }, {
            field: 'editedByName',
            title: 'T_LIMS_EDIT_RECORD.EDITEDBYNAME',
            width: 160
        }, {
            field: 'editedTime',
            title: 'T_LIMS_EDIT_RECORD.EDITEDTIME',
            width: 160
        }]
    },
});
